﻿using UnityEngine;
using System.Collections;
using System.Text;

public class Debuger
{
    public static bool EnableLog = true;

    static UdpSocket mUdpSocket = null;

    public static UdpSocket UdpSocket
    {
        get
        {
            if (mUdpSocket == null)
            {
                mUdpSocket = new UdpSocket();
                mUdpSocket.BindSocket(18001, 1024, null);
            }
            return mUdpSocket;
        }
    }

    public static void Log(object message, Object context)
    {
        if (EnableLog)
        {
            if (Application.platform == RuntimePlatform.WindowsEditor ||
                Application.platform == RuntimePlatform.OSXEditor)
            {
                Debug.Log(message, context);
            }
            else
            {
                byte[] data = Encoding.Default.GetBytes(message.ToString());
                mUdpSocket.SendData("", data, 18001);

                //  mUdpSocket.SendData("255,255,255,255", data, 18001);
            }
        }
    }
}
